<?php
require_once __DIR__ . '/vendor/autoload.php';
use Workerman\Worker;
$ws_worker = new Worker('websocket://0.0.0.0:8181');
$ws_worker->name = 'haha';
$ws_worker->count = 4;
$ws_worker->onConnect = function($connection)
{
    echo "New connection\n";
 };
$ws_worker->onMessage = function($con, $msg) {
    echo "get data: $msg\n";
    $con->send('Hello');
};
$ws_worker->onClose = function($connection)
{
    echo "Connection closed\n";
};
Worker::runAll();